﻿using Core.Model.Chunks;
using Core.Model.Types;
using SlimDX.DXGI;
using SlimDX.Direct3D10;
using Device = SlimDX.Direct3D10.Device;

namespace SlimDX.Game.Model
{
    public class SlimDxChunk : Chunk
    {
        public Buffer IndexBuffer;
        public Buffer VertexBuffer;

        public SlimDxChunk(VectorIndex index)
            : base(index)
        {
        }

        public void DrawChunk(Device device, EffectPass pass)
        {
            device.InputAssembler.SetIndexBuffer(IndexBuffer, Format.R32_UInt, 0);

            device.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            device.InputAssembler.SetVertexBuffers(0,
                                                   new VertexBufferBinding(VertexBuffer,
                                                                           BlockVertex.BlockVertexSize, 0));

            pass.Apply();

            device.DrawIndexed(IndexCount, 0, 0);
        }
    }
}